﻿using Prism.Commands;
using Prism.Mvvm;
using Prism.Services.Dialogs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DailyApp.WPF.ViewModels
{
    public class LoginUCViewModel : BindableBase, IDialogAware
    {
        public string Title { get; set; } = "我的日常";

        public event Action<IDialogResult> RequestClose;

        public DelegateCommand LoginCommand { get; set; }

        public LoginUCViewModel()
        {
            //登录命令
            LoginCommand = new DelegateCommand(Login);
            //显示注册信息
            ShowRegCmd = new DelegateCommand<string>(ShowRegInfo);
        }

        private void Login()
        {
            string input = Pwd;
            //模拟登录
            RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
        }

        public bool CanCloseDialog()
        {
            return true;
        }

        public void OnDialogClosed()
        {

        }

        public void OnDialogOpened(IDialogParameters parameters)
        {

        }

        #region 显示内容
        //显示内容的下标
        private int _selectIndex;

        public int SelectIndex
        {
            get
            {
                return _selectIndex;
            }
            set
            {
                _selectIndex = value;
                RaisePropertyChanged();
            }
        }

        public DelegateCommand<string> ShowRegCmd { get; set; }

        private void ShowRegInfo(string index)
        {
            //SelectIndex = int.Parse(index);
            SelectIndex = Convert.ToInt32(index);
        }


        #endregion

        #region
        private string _pwd;

        public string Pwd
        {
            get { return _pwd; }
            set { _pwd = value; }
        }


        #endregion

    }
}
